<?
 require("employee.php");
 
 if(isset($_POST['edit']))
 {
 	if($_POST['edit'] === '1')
	{
		$results = updateEmployee($_POST);	

		header('location:list.php');
	}
 }
 
  /*
  * 
						<? if($results) :?>
						<dl>
							<? foreach ($variable as $key => $value): ?>
							
								<dt><?=$key?></dt>
								<dd><?=$value?></dd>
							<? endforeach; ?>
							
						</dl>
						<? endif; ?>	 	
  * 
  */
 //$results = array();
//<img src="../images/stiglogo.png" alt="" class="img-polaroid">

 $results = getEmployeeInfo($_GET['id']);

 $employee = $results->fetch_assoc();
 
 $employee['user_id'] = htmlentities($row['user_id']);
 $employee['first_name'] = htmlentities($row['first_name']);
 $employee['middle_name'] = htmlentities($row['middle_name']);
 $employee['last_name'] = htmlentities($row['last_name']);
 
?>
<!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title><?=$title ?> Edit Employee: <?=$employee['user_id'] ?></title>
         <? require('../inc/header-info.php'); ?>
    </head>
    <body>
        <div class="container">
            <? include('../inc/nav.php'); ?>
             <form name="form1" method="post" action="edit.php">
             	<h4>Edit Employee: </h4>
             	<input type="hidden" name="edit" value='1'> 
            	<input type="hidden" name="id" value='<?=$employee['id'] ?>'> 
					<label class="control-label" for="user_id">User ID:</label>
					<div class="controls">
						<input type="text" id="user_id" name="user_id" placeholder="User ID" value="<?=$employee['user_id'] ?>">
					</div>
				
    			
					<label class="control-label" for="first_name">First Name:</label>
					<div class="controls">
						<input type="text" id="first_name"  name="first_name" placeholder="First Name" value="<?=$employee['first_name'] ?>">
					</div>
				
				
					<label class="control-label" for="middle_name">Middle Name:</label>
					<div class="controls">
						<input type="text" id="middle_name" name="middle_name" placeholder="Middle Name" value="<?=$employee['middle_name'] ?>">
					</div>
				
					<label class="control-label" for="last_name">Last Name:</label>
					<div class="controls">
						<input type="text" id="last_name" name="last_name" placeholder="Last Name" value="<?=$employee['last_name'] ?>">
					</div>
    			
    				<label class="control-label">Security Level</label>
    				<div class="controls">
    					<select name='access_index'>
							<option value='15'>Administrator</option>			
							<option value='16'>User</option>
						</select>
    				</div>			
            	<div class="form-actions">
  					<button type="submit" class="btn btn-primary">Save changes</button>
					<a href="<?=$url?>employees/index.php"><button class="btn btn-primary" type="button">Cancel</button></a>
				</div>	
            </form> 
		</div>
		
		<div class="modal hide fade">
        	<div class="modal-header">
            	<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h3>Delete</h3>
            </div>
            <div class="modal-body">
            	<p>Are you sure etc.</p>
            </div>
		</div>

		<script type="application/javascript" src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
		
 		<script>
 			
 			$(function()
 			{
 				
 				$("#newEmail").validate({
 						rules: 
 						{	newEmail: { required: true }	}
					
				});
			});
			
  		</script>
	</body>
</html>